package com.shopping_back.controller;

import com.shopping_back.service.CaptchaService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/captcha")
@RequiredArgsConstructor
public class CaptchaController {

    final CaptchaService captchaService;

    @GetMapping("/sendCaptcha")
    public String testSendCaptcha(@RequestParam String email) {
        try {
            captchaService.sendEmailCaptcha(email);
            return "验证码已发送";
        } catch (Exception e) {
            return "发送失败：" + e.getMessage();
        }
    }
}